import request from '@/modules/index/utils/request';
const store = {
    namespaced: true,
    actions: {
        // 用户列表
        async userSearch(context, params) {
            const data = await request({
                url: '/user/search',
                method: 'get',
            });
            return data;
        },
        // 获取单个用户
        async userSearchByUsername(context, params) {
            const data = await request({
                url: '/user/search-by-username',
                method: 'get',
                params: params
            });
            return data;
        },
        // 获取角色管理列表
        async getRoleTableList(context, params) {
            const data = await request({
                url: '/sys/role/list',
                method: 'post',
                data: params
            });
            return data;
        },
        // 获取角色管理列表-删除
        async deleteRoleTableList(context, params) {
            const data = await request({
                url: '/sys/role/delete',
                method: 'post',
                data: params
            });
            return data;
        },
        // 获取角色管理列表-新增
        async addRoleTableList(context, params) {
            const data = await request({
                url: '/sys/role/save',
                method: 'post',
                data: params
            });
            return data;
        },
        // 根据id获取单个数据
        async getRoleDataById(context, id) {
            const data = await request({
                url: '/sys/role/' + id,
                method: 'get',
                data: {}
            });
            return data;
        },
        // 获取全部角色权限
        async getRoleAuthList(context, id) {
            const data = await request({
                url: '/sys/menu/list',
                method: 'get',
                data: {}
            });
            return data;
        },
        // 根据id获取角色权限
        async getRoleAuthById(context, id) {
            const data = await request({
                url: "sys/role/menus/" + id,
                method: 'get',
                data: {}
            });
            return data;
        },
        // 角色权限-设置
        async setRoleAuth(context, params) {
            const data = await request({
                url: "sys/role/updateMenus/" + params.id,
                method: 'post',
                data: params.menuIds
            });
            return data;
        }
    }
};

export default store;
